﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NET.Library.Web.Forms.DataControls.FormViews
{
    /// <summary>
    /// Reference Web Controls in a FormView Control.
    /// </summary>
    public class FormViewControls
    {
        #region Static Methods
        ///----------------------------------------------------------------------------------
        /// <summary>
        /// HyperLink Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns>HyperLink</returns>
        ///----------------------------------------------------------------------------------
        public static HyperLink HyperLinkControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as HyperLink;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// Label Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static Label LabelControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as Label;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// Literal Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static Literal LiteralControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as Literal;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// TextBox Control Reference
        /// </summary>
        /// <param name="controlName">ID of the Control</param>
        /// <param name="formView"></param>
        /// <returns>TextBox</returns>
        ///----------------------------------------------------------------------------------
        public static TextBox TextBoxControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as TextBox;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// Image Control Reference
        /// </summary>
        /// <param name="controlName">ID of the Control</param>
        /// <param name="formView"></param>
        /// <returns>TextBox</returns>
        ///----------------------------------------------------------------------------------
        public static Image ImageControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as Image;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// CheckBox Control Reference
        /// </summary>
        /// <param name="controlName">ID of the Control</param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static CheckBox CheckBoxControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as CheckBox;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// CheckBoxList Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static CheckBoxList CheckBoxListControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as CheckBoxList;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// RadioButton Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static RadioButton RadioButtonControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as RadioButton;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// RadioButtonList Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static RadioButtonList RadioButtonListControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as RadioButtonList;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// Button Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static Button ButtonControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as Button;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// Calendar Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static Calendar CalendarControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as Calendar;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// DropDownList Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static DropDownList DropDownListControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as DropDownList;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// FileUpload Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static FileUpload FileUploadControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as FileUpload;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// HiddenField Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static HiddenField HiddenFieldControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as HiddenField;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        /// ImageButton Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static ImageButton ImageButtonControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as ImageButton;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        ///  Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static LinkButton LinkButtonControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as LinkButton;
        }

        ///----------------------------------------------------------------------------------
        /// <summary>
        ///  Control Reference
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="formView"></param>
        /// <returns></returns>
        ///----------------------------------------------------------------------------------
        public static ListBox ListBoxControl(string controlName, FormView formView)
        {
            return Control(controlName, formView) as ListBox;
        }
        #endregion

        #region Private Methods
        ///----------------------------------------------------------------------------------
        /// <summary>
        /// Generic Control Reference
        /// </summary>
        /// <remarks>Used internally for all Control types.</remarks>
        /// <param name="controlName">ID of the Control</param>
        /// <param name="formView"></param>
        /// <returns>Control</returns>
        ///----------------------------------------------------------------------------------
        private static Control Control(string controlName, FormView formView)
        {
            return formView.FindControl(controlName);
        }
        #endregion
    }
}
